package com.cakemallproject.mapper;

import com.cakemallproject.pojo.mapperObj.Cart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface CartMapper {
    @Select("select * from cart where status != 0")
    List<Cart> list();

    @Select("select * from cart where status != 0 and uid = #{uid}")
    List<Cart> getByUid(Integer uid);

    @Insert("insert cart(uid, gid, num) values(#{uid},#{gid},#{num})")
    void insert(Cart cart);

    List<Cart> getCartListByCid(List<Integer> cartIds);

    void delete(List<Integer> cartIds);

    @Update("update cart set num = #{num}, update_time = now() where status = 1 and cid = #{cid}")
    void update(Cart cart);
}
